home *** CD-ROM | disk | FTP | other *** search
-
- function createHint() {
- var eDiv = document.createElement("DIV");
- eDiv.style.fontFamily = "Tahoma";
- eDiv.style.fontSize = "8pt";
- //eDiv.style.width = 150;
- //eDiv.style.height = 80;
- eDiv.style.display = "inline";
- eDiv.style.textAlign = "left";
- eDiv.style.border = "solid 1px silver";
- eDiv.style.position = "absolute";
- eDiv.style.backgroundColor = "#FFFFBF";
- eDiv.style.left = 10;
- eDiv.style.top = 10;
- eDiv.style.padding = "5px";
- eDiv.style.visibility = "hidden";
- eDiv.style.cursor = "default";
- return eDiv;
- }
-
- var hintDiv = createHint();
- document.body.appendChild(hintDiv);
-
- function mouseX(evt) {
- if (evt.pageX)
- return evt.pageX;
- else if (evt.clientX)
- return evt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
- else
- return null;
- }
-
- function mouseY(evt) {
- if (evt.pageY)
- return evt.pageY;
- else if (evt.clientY)
- return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
- else
- return null;
- }
-
- function showHint(s) {
- hintDiv.innerHTML = s;
- hintDiv.style.visibility = "visible";
- hintDiv.style.left = mouseX(event) + 10;
- hintDiv.style.top = mouseY(event) + 10;
- }
-
- function hideHint() {
- hintDiv.style.visibility = "hidden";
- }
-
- var showSelectedElements;
- var selectedElement;
-
- // Enables the xray on selected elements
- function enableClicks() {
- docElements = document.getElementsByTagName("*");
- for (var i = 0; i < docElements.length; i++) {
- docElements[i].onclick = onElementClick;
- }
- }
-
- function onElementClick(evt) {
-
- hideSelection(); // hide old selection
-
- if (!evt) var evt = window.event;
- if (evt.target) var elem = evt.target; else if (evt.srcElement) var elem = evt.srcElement;
- while (elem.nodeName == '#text') elem = elem.parentNode;
-
- selectedElement = elem;
- if (showSelectedElements == true) {
-
- /* if (elem.currentStyle) {
- cstr = elem.currentStyle.cssText;
- } else {
- var astyle = window.getComputedStyle(elem, null);
- cstr = astyle.cssText;
- } */
-
- shint = '<b>' + elem.tagName + '</b><br>';
- if (elem.className != '') shint = shint + 'class: ' + elem.className + '<br>';
- if (elem.id != '') shint = shint + 'id: ' + elem.id + '<br>';
- if (elem.style.cssText != '') shint = shint + 'style: ' + elem.style.cssText.toLowerCase() + '<br>';
-
- showHint(shint);
-
- elem.style.border = 'solid 1px red';
-
- }
-
- }
-
- function hideSelection() {
- if (selectedElement != null) {
- selectedElement.style.borderColor = '';
- selectedElement.style.borderWidth = '';
- selectedElement.style.borderStyle = '';
- }
- }
-
- enableClicks();
- showSelectedElements=true;